﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;

namespace ElectronicCommerce.Framework.Data.Attribute
{
    public class DataMappingAttribute : System.Attribute
    {
        private string m_ColumnName;
        private DbType m_DbType;
        private bool m_ISPrimaryKey;

        public DataMappingAttribute(string columnName, DbType dataType, bool isPrimaryKey, bool isPrimaryKeyIdentity)
        {
            m_ColumnName = columnName;
            m_DbType = dataType;
            m_ISPrimaryKey = isPrimaryKey;
            ISPrimaryKeyIdentity = isPrimaryKeyIdentity;
        }

        public DataMappingAttribute(string columnName, DbType dataType)
        {
            m_ColumnName = columnName;
            m_DbType = dataType;
        }

        public DataMappingAttribute(string columnName, DbType dataType, bool isExternal)
        {
            m_ColumnName = columnName;
            m_DbType = dataType;
            IsExternal = isExternal;
        }

        public DataMappingAttribute(string columnName, bool isPrimaryKey)
        {
            m_ColumnName = columnName;
            m_ISPrimaryKey = isPrimaryKey;
        }

        public DataMappingAttribute(string columnName)
        {
            m_ColumnName = columnName;
        }

        public DataMappingAttribute(bool isPrimaryKey)
        {
            m_ISPrimaryKey = isPrimaryKey;
        }

        private Type m_CaculatorType;

        public Type CaculatorType
        {
            get { return m_CaculatorType; }
            set { m_CaculatorType = value; }
        }

        public string ColumnName
        {
            get { return m_ColumnName; }
        }

        public DbType DbType
        {
            get { return m_DbType; }
        }

        public bool ISPrimaryKey
        {
            get { return m_ISPrimaryKey; }
        }

        public bool ISPrimaryKeyIdentity { get; private set; }

        /// <summary>
        /// 外部字段, 设置为true 的时候,在单表查询不实用此字段,只有分页查询的才使用.
        /// </summary>
        public bool IsExternal { get; set; }
    }
}
